#include <apue.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>

int main()
{
	int fd, size;
	struct sockaddr_un un;

	un.sun_family = AF_INET;
	strcpy(un.sun_path, "/root/unix/streams/foo.socket");

	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("socket failed\n");
	}

	size = offsetof(struct sockaddr_un, sun_path) + strlen(un.sun_path);

	struct sockaddr_in shit;

	shit.sin_family = AF_INET;
	shit.sin_port = htons(1025);
	shit.sin_addr.s_addr = htonl(INADDR_ANY);
	if (bind(fd, (struct sockaddr *)&un, size) < 0) {
		printf("bind failed\n");
	}

	printf("unix domain socket bound\n");
	exit(0);
}
